<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <body>
        <ui:composition template="../templates/default3.xhtml">        
            <ui:define name="content">
                <h:form id="addProductionSchedule" binding="#{productionScheduleManagerBean.loadUpdateProductionSchedule_ps}">
                    <p:messages id="error"/>
                    <p:panel header="Annual Production vs Annual Forecast" >
                        <p:columnChart model="#{productionScheduleManagerBean.model}" titleY="Bars" titleX="Products" width="800px"   />  
                    </p:panel>
                    <p:panel header="Production information #{productionScheduleManagerBean.consolidatedMthSalesFc.salesYear}" id="productionSchedule" >


                        <p:dataTable id="productionSchedules" var="productionSchedule" value="#{productionScheduleManagerBean.productionSchedules}" selectionMode="single" 
                                     selection="#{productionScheduleManagerBean.productionSchedule}" update ="productionSchedules" paginator="true" rows="12"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}" >

                            <p:column  headerText="Line No." >  
                                <center><h:outputText value="#{productionSchedule.lineNumber}" /> </center> 
                            </p:column> 

                            <p:column  headerText="Month" >  
                                <center><h:outputText value="#{productionSchedule.operationMonth}" /> </center> 
                            </p:column> 
                            <p:column  headerText="Days available" >  
                                <center><h:outputText value="#{productionSchedule.totalNormalOperatingHours}" /> </center> 
                            </p:column> 
                            <p:column  headerText="Days utilized" >  
                                <center><h:outputText value="#{productionSchedule.totalNormalUtilizedOperatingHours}" /> </center> 
                            </p:column> 
                            <p:column  headerText="Utilization rate" >  
                                <center><h:outputText value="#{productionSchedule.utilizationRate}" /> </center> 
                            </p:column> 

                            <p:columnGroup type="footer">  
                                <p:row>  
                                    <p:column colspan="4" footerText="Average Utilization per month (%):" style="text-align:right"/>
                                    <p:column footerText="#{productionScheduleManagerBean.aveUtilizationRate}"/>

                                </p:row>   


                            </p:columnGroup>  


                        </p:dataTable>

                        <center><p:commandButton id="btnCompute" value="Edit" actionListener="#{productionScheduleManagerBean.editProductionPlan}" ajax="true" update="error " />
                        </center>
                        <br/>
                        <br/>
                        <hr/>
                        <center><p:commandButton id="btnDone" value="Done" onclick="confirmation2.show()" ajax="true" update="error" />
                        </center>
                    </p:panel>
                    
                     <p:confirmDialog message="You are about to finalize the production schedule for next month. This schedule will forward to warehouse department for raw material purchasing. Are you sure you want to proceed?"
                                     header="Final production schedule..." severity="alert" widgetVar="confirmation2">
                        <p:commandButton value="Yes" update="quotationItemsPanel" oncomplete="confirmation.hide()"
                                         actionListener="#{productionScheduleManagerBean.doneUpdateProductionSchedule}"/>
                        <p:commandButton value="No" update="quotationItemsPanel" onclick="confirmation2.hide()" type="button"/>
                    </p:confirmDialog>
                        
                        
                         <p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>  
                <p:dialog modal="true" widgetVar="statusDialog" header="Please wait..."   
                          draggable="false" closable="false">  
                    <p:graphicImage value="../resources/images/ajaxloadingbar.gif" />  
                </p:dialog>

               
                    
                  
                        

                    <br/>




                </h:form>
            </ui:define>        
        </ui:composition>
    </body>
</html>
